package de.mmis.core.pojop.processor;

import java.util.Map;

import de.mmis.core.base.ObjectDescriptor;
import de.mmis.core.base.abstracttree.Tree;
import de.mmis.core.pojop.answer.AbstractAnswer;
import de.mmis.core.pojop.answer.AbstractAnswer.Type;
import de.mmis.core.pojop.answer.Answer;
import de.mmis.core.pojop.request.AbstractRequest;

public class SimpleRequestProcessorFactory extends
		AbstractRequestProcessorFactory<AbstractRequest> {

	public SimpleRequestProcessorFactory(ObjectDescriptor objectDescriptor,
			String objectID, Map<String, Object> objectProperties,
			boolean explicit) {
		super(objectDescriptor, objectID, objectProperties, explicit);
	}

	@Override
	public RequestProcessorFactory.RequestProcessor<AbstractRequest> createRequestProcessor() {
		return new SimpleRequestProcessor();
	}

	public class SimpleRequestProcessor extends AbstractRequestProcessor {
		@Override
		public Answer answerRequest(AbstractRequest request) {
			return answerAbstractRequest(request);
		}

		@Override
		protected void processEvent(Tree exp) {
			fireEvent(new RequestProcessorEvent(new AbstractAnswer(Type.Event,
					exp)));
		}
	}
}
